package ua.com.jpy.entity.customer;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.bson.types.ObjectId;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import ua.com.jpy.entity.AEntity;
import ua.com.jpy.entity.IEntity;

import com.google.code.morphia.annotations.Entity;

/**
 * @author LSD25
 *
 */
@Entity(noClassnameStored = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Customer extends AEntity implements IEntity, UserDetails {

	private static final long serialVersionUID = 2515348534448047180L;
	
//	@NotBlank
//	@Valid
//	private String customerName;

	@DateTimeFormat
	private Date dateTime;

	@DateTimeFormat
	private Date dateRegistration;
	
	private String interesting;
	
//	@DecimalMin(value = "1", message = "Discount has been above zero")
	private double discount;
	
	@NotEmpty(message = "Address is not blank or null")
	private List<String> addreses;
	
//	@DecimalMin(value = "1", message = "Discount has been above zero")
	private int countBuy;
	
//	@DecimalMin(value = "1", message = "Sum has been above zero")
	private double sumBuy;
	
	private boolean newsletters;
	
	private Map<ObjectId, Integer> cart;

//	public String getCustomerName() {
//		return customerName;
//	}
//
//	public void setCustomerName(String customerName) {
//		this.customerName = customerName;
//	}
	
	public Date getDateTime() {
		return dateTime;
	}

	public void setDateTime(Date dateTime) {
		this.dateTime = dateTime;
	}

	public Date getDateRegistration() {
		return dateRegistration;
	}

	public void setDateRegistration(Date dateRegistration) {
		this.dateRegistration = dateRegistration;
	}

	public String getInteresting() {
		return interesting;
	}

	public void setInteresting(String interesting) {
		this.interesting = interesting;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public List<String> getAddreses() {
		return addreses;
	}

	public void setAddreses(List<String> addreses) {
		this.addreses = addreses;
	}

	public int getCountBuy() {
		return countBuy;
	}

	public void setCountBuy(int countBuy) {
		this.countBuy = countBuy;
	}

	public double getSumBuy() {
		return sumBuy;
	}

	public void setSumBuy(double sumBuy) {
		this.sumBuy = sumBuy;
	}

	public boolean isNewsletters() {
		return newsletters;
	}

	public void setNewsletters(boolean newsletters) {
		this.newsletters = newsletters;
	}

	public Map<ObjectId, Integer> getCart() {
		return cart;
	}

	public void setCart(Map<ObjectId, Integer> cart) {
		this.cart = cart;
	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return this.getRoles();
	}

	@Override
	public String getUsername() {
		// TODO Auto-generated method stub
		return this.getLogin();
	}

	@Override
	public boolean isAccountNonExpired() {
		return false;
	}

	@Override
	public boolean isAccountNonLocked() {
		return false;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return false;
	}

	@Override
	public boolean isEnabled() {
		return this.isEnabled();
	}
	
}
